package com.jamesacurtis.MyBudget;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;

public class QuickExpense extends Activity {
    int expenseAmount;
    String cat;
    RadioButton food, entertainment, hobby, clothes, other;
	Button addButton, clearButton;
    EditText expenseField;
	// Called when the activity is first created.
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        setContentView(R.layout.quickexpense);
        
        setupControls();
        addButton.setOnClickListener(new Button.OnClickListener() {
		    
		    //get radios 
		    public void onClick (View v){
		    	setCategory();
		    	String value = expenseField.getText().toString();
		    	expenseAmount = Integer.parseInt(value);
		    	Toast.makeText(QuickExpense.this, "Amount:" + expenseAmount + ":" + cat , Toast.LENGTH_SHORT).show();
		    }
	 });
        
        clearButton.setOnClickListener(new Button.OnClickListener(){

			public void onClick(View v) {
				expenseField.setText("0000");
				
			}
        	
        	
        });
        
        
	}
	
	
    protected void setCategory() {
    	if(food.isChecked()){
			 cat = "Food";
			 
		 }
		 if(entertainment.isChecked()){
			 cat = "Entertainment";
			 
		 }
		 if(hobby.isChecked()){
			 cat = "Hobby";
			 
		 }if(clothes.isChecked()){
			 cat = "Cloth";
			 
		 }
		 if(other.isChecked()){
			 cat = "Other";
			 
		 }

	}


	private void setupControls() {
		food = (RadioButton)findViewById(R.id.foodRAD);
		entertainment = (RadioButton)findViewById(R.id.entertain);
		hobby = (RadioButton)findViewById(R.id.hobbies);
		clothes = (RadioButton)findViewById(R.id.clothes);
		other = (RadioButton)findViewById(R.id.other);
		addButton = (Button)findViewById(R.id.add_button);
		clearButton = (Button)findViewById(R.id.clear_button);
		expenseField = (EditText)findViewById(R.id.quickexfield);
	}
	
}